package owl2vowl.model.ontology;

import owl2vowl.model.data.VowlData;
import java.util.Map;
import org.semanticweb.owlapi.metrics.ReferencedClassCount;
import org.semanticweb.owlapi.metrics.ReferencedDataPropertyCount;
import org.semanticweb.owlapi.metrics.ReferencedIndividualCount;
import org.semanticweb.owlapi.metrics.ReferencedObjectPropertyCount;
import org.semanticweb.owlapi.model.OWLOntology;

public class OntologyMetric {
	private OWLOntology ontology;
	private int classes;
	private int objectProperties;
	private int datatypeProperties;
	private int individuals;
	private int nodes;
	private int edges;

	public OntologyMetric(OWLOntology ontology) {
		this.ontology = ontology;
		calculateOntologyMetrics();
	}

	private void calculateOntologyMetrics() {
		this.classes = ((Integer) new ReferencedClassCount(this.ontology).getValue()).intValue();
		this.objectProperties = ((Integer) new ReferencedObjectPropertyCount(this.ontology).getValue()).intValue();
		this.datatypeProperties = ((Integer) new ReferencedDataPropertyCount(this.ontology).getValue()).intValue();
		this.individuals = ((Integer) new ReferencedIndividualCount(this.ontology).getValue()).intValue();
	}

	public void calculate(VowlData vowlData) {
		int classCount = vowlData.getClassMap().size();
		int datatypeCount = vowlData.getDatatypeMap().size();
		int objectPropertyCounts = vowlData.getObjectPropertyMap().size();
		int dataPropertyCount = vowlData.getDatatypePropertyMap().size();

		this.nodes = (classCount + datatypeCount);
		this.edges = (objectPropertyCounts + dataPropertyCount);
	}

	public int getClasses() {
		return this.classes;
	}

	public int getObjectProperties() {
		return this.objectProperties;
	}

	public int getDatatypeProperties() {
		return this.datatypeProperties;
	}

	public int getIndividuals() {
		return this.individuals;
	}

	public int getNodes() {
		return this.nodes;
	}

	public int getEdges() {
		return this.edges;
	}

	public String toString() {
		return "OntologyMetric{classes=" + this.classes + ", objectProperties=" + this.objectProperties
				+ ", datatypeProperties=" + this.datatypeProperties + ", individuals=" + this.individuals + ", nodes="
				+ this.nodes + ", edges=" + this.edges + '}';
	}
}
